//
//  CommonTools.h
//
//  Created by ttouch on 17/10/8.
//  Copyright © 2017年 肖兰月. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <AVFoundation/AVFoundation.h>
#import <Photos/PHPhotoLibrary.h>

@interface CommonTools : NSObject

#pragma mark - 应用信息
+ (NSString *)appDisplayName;
+ (NSString *)appBundleName;
+ (NSString *)appVersion;
+ (BOOL)needShowNewFeature;

#pragma mark - 文本计算
/// 计算文字size
+ (CGSize)sizeOfText:(NSString *)text fontSize:(CGFloat)fontSize;
+ (CGSize)sizeOfText:(NSString *)text fontSize:(CGFloat)fontSize width:(CGFloat)width;
+ (CGSize)sizeOfText:(NSString *)text fontSize:(CGFloat)fontSize width:(CGFloat)width height:(NSInteger)height;

#pragma mark - 正则验证
/// 是否是全数字
+ (BOOL)isNumText:(NSString *)text;
/// 是否是身份证
+ (BOOL)validateIdentityCard: (NSString *)identityCard;
/// 验证手机号
+ (BOOL)isMobileNumber:(NSString *)mobileNum;
/// 验证电子邮件
+ (BOOL)isEmail:(NSString *)email;
/// 验证qq
+ (BOOL)isQqNumber:(NSString *)qqNum;
/// 验证银行卡号
+ (BOOL)isBankCardNumber: (NSString *)bankCardNumber;

#pragma mark - 颜色相关
/// 随机颜色
+ (UIColor *)colorLightRandom;
/// 以UIColor生成一张UIImage
+ (UIImage *)imageCreateWithColor:(UIColor *)color;
+ (UIImage *)imageCreateWithColor:(UIColor *)color size:(CGSize)size;
+ (UIImage *)createImageWithColor:(UIColor *)color width:(CGFloat)width;

#pragma mark - 图片相关
/// 压缩图片尺寸，方便上传服务器
+ (UIImage *)scaleImage:(UIImage *)img size:(CGSize)size;
+ (UIImage *)scaleImage:(UIImage *)image scale:(CGFloat)scale;
// 压缩到多少kb,返回一个字典，里面有image和imagedata
+ (NSDictionary *)scaleImage:(UIImage *)image toKByte:(NSInteger)kByte;
+ (NSData *)resetSizeOfImageData:(UIImage *)sourceImage maxSize:(NSInteger)maxSize;

#pragma mark - 时间戳 <-> 时间字符串 转换
/// 时间戳 -> 时间字符串 dateFormat默认为yyyy-MM-dd
+ (NSString *)getTimeStrBytimeStamp:(NSString *)timeStam;
+ (NSString *)getTimeStrBytimeStamp:(NSString *)timeStamp dateFormat:(NSString *)dataFormat;
/// 时间字符串 -> 时间戳 dateFormat默认为yyyy-MM-dd
+ (NSString *)getTimeStampBytimeStr:(NSString *)timeStr;
+ (NSString *)getTimeStampBytimeStr:(NSString *)timeStr dateFormat:(NSString *)dataFormat;

#pragma mark - 富文本字符串处理
/// 返回NSAttributedString，左侧String为灰色，右侧为TZMainColor
+ (NSAttributedString *)getAttributedStringWithFirstString:(NSString *)firstStr firstColor:(UIColor *)firstColor lastString:(NSString *)lastStr lastColor:(UIColor *)lastColor fontSize:(CGFloat )fontSize;

#pragma mark - 距离计算
/// 2个坐标距离
+ (NSString *)locationWithLatitude:(NSString *)firstLatitude withLongitude:(NSString *)firstLongitude WithLatitude:(NSString *)secondLatitude withLongitude:(NSString *)secondLongitude;

#pragma mark - 其他
/// 防止nil，如果是nil,返回空字符串
+ (NSString *)avoidNil:(NSString *)str;
/// 检查value是否为空，是空则返回NO,非空返回YES
+ (BOOL)isNotNull:(id)value;
/// 判断字符串是否为空
+ (BOOL)isBlankString:(NSString *)string;
/// 判断文件夹是否存在
+ (BOOL)isExistFile:(NSString *)path;

#pragma mark - 相册权限
+ (BOOL)albumAuthority;
#pragma mark - 相机权限
+ (BOOL)canRecordViedo;
#pragma mark - 去设置是否开启定位
+ (void)gotoSetting;


#pragma mark - 字符串去前后空格
+ (NSString *)stringGoesBeforeAndAfterTheSpace:(NSString *)string;

@end
